package com.autosalon.ui.automobil.action;

import com.autosalon.ui.automobil.Automobil;
import com.autosalon.ui.automobil.state.AutomobilStateHolder;
import com.vaadin.ui.Button.ClickEvent;
/**
 *  Nastaveni stavu pro formular vkladani automobilu
 * @author Petr Kriegisch
 */

public class NewAutomobilAction extends AbstractAutomobilAction{
	
	public NewAutomobilAction(Automobil automobil){
		super(automobil);
	}

	@Override
	public void buttonClick(ClickEvent event) {
		int id;
                automobil.initFormNewCar();
		try{
			id = automobil.getSwitcher().getMainWindow().getZakaznik().getRole().getId().intValue();
		}catch (NullPointerException e) {
			id = 1;
		}
		AutomobilStateHolder.setState(AutomobilStateHolder.NEW_AUTOMOBIL_STATE, id, super.automobil );
	}

}
